//
//  UILabel+AlertViewAutoDisappear.m
//  豆瓣
//
//  Created by lanou on 15/10/18.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "UILabel+AlertViewAutoDisappear.h"

@implementation UILabel (AlertViewAutoDisappear)
+ (void)alertViewAutoDisappearWithTitle:(NSString *)title viewController:(UIViewController *)viewController
{
    //添加要用到的Label
    
    
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake((375 - 320)/2, 0, 320, 25)];
    label.backgroundColor = [UIColor redColor];
    label.textAlignment = UITextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:14];
    label.text = title;
    [viewController.view addSubview:label];
    
    
    
    
    //设置动画
    CATransition * transion = [CATransition animation];
    transion.type = @"push";//设置动画方式
    transion.subtype = @"fromTop";//设置动画从那个方向开始
    [label.layer addAnimation:transion forKey:nil];//给Label.layer 添加动画
    //设置延时效果
    
    
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(),^{
        [label removeFromSuperview];
    });//这句话的意思是1.5秒后，把label移出视图
}
@end
